local lu = require 'luaunit'
local c_controller = require 'controller.controller_object'
local battery_collection = require 'battery.battery_collection'

TestUpdateControllerBatteryInfo = {}

function TestUpdateControllerBatteryInfo:test_update_controller_battery_info()
    local controller = {
        Id = 0,
        BatteryPresence = 1,
        BatteryFault = 255,
        BatteryHealth = 1,
        presence_debounce = {}
    }
    controller.presence_debounce.get_debounced_val = function()
        return true
    end
    local battery = {
        Fault = 0
    }
    battery.get_capcacitance_by_controller_id = function(id)
        return {State = 1, Fault = 0, Health = 1}
    end
    battery_collection.get_instance = function()
        return battery
    end
    local ok = pcall(c_controller.update_controller_battery_info, controller)
    lu.assertEquals(ok, true)
    lu.assertEquals(controller.BatteryFault,0)
end
